package com.tjsinfo.tjsoa.workplan.action;

import java.util.Date;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tjsinfo.tjsoa.system.bo.ISystemUserBo;
import com.tjsinfo.tjsoa.system.vo.TSystemUser;
import com.tjsinfo.tjsoa.workplan.vo.WorkPlanMain;

public class CheckDefalntWorkPlanMonthModleAction extends WorkPlanMonthModleAction{
	private ISystemUserBo systemUserBo;
	
	public ISystemUserBo getSystemUserBo() {
		return systemUserBo;
	}

	public void setSystemUserBo(ISystemUserBo systemUserBo) {
		this.systemUserBo = systemUserBo;
	}

	/* (non-Javadoc)
	 * @see com.tjsinfo.tjsoa.workplan.action.WorkPlanMonthModleAction#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
	 */
	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		// TODO Auto-generated method stub
		try {
			Integer userid = Integer.parseInt(request.getParameter("id")); 
			
			TSystemUser systemUser = systemUserBo.findByIdSystemUser(Integer.parseInt(request.getParameter("id")));
			request.setAttribute("systemUser", systemUser);
			Date date = new Date();
			Map<Integer, WorkPlanMain> map =	workPlanMainBo.selectWorkPlanTypeAndYearMAPNumberStart("M", date.getYear() +1900, userid, 1);
			
			return forword(mapping, request, date, map);
		} catch (RuntimeException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return mapping.findForward("error");
		}
	}

	/* (non-Javadoc)
	 * @see com.tjsinfo.tjsoa.workplan.action.WorkPlanMonthModleAction#forword(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest, java.util.Date, java.util.Map)
	 */
	@Override
	protected ActionForward forword(ActionMapping mapping,
			HttpServletRequest request, Date date,
			Map<Integer, WorkPlanMain> map) {
		// TODO Auto-generated method stub
		request.setAttribute("userid", Integer.parseInt(request.getParameter("id")));
		return super.forword(mapping, request, date, map);
	}	
	
}
